﻿<UserControl x:Class="DotBeer.UI.WPFClient.TavernsCollectionControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:business="clr-namespace:DotBeer.Business.Entities;assembly=DotBeer.Business.Entities"
             Height="Auto" 
             Width="Auto"
             xmlns:PresentationLayer="clr-namespace:DotBeer.UI.WPFClient">
    <UserControl.Resources>
        <ObjectDataProvider x:Key="sideData"
							MethodName="GetValues"
							ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="business:Side"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" MinWidth="100" MaxWidth="200"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListBox Style="{DynamicResource ListBoxStyle}" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" Name="ListBoxTaverns" KeyUp="ListBoxTaverns_KeyUp" Margin="5,5,5,5" />
        <Grid Grid.Column="1">
        	<Grid.ColumnDefinitions>
        		<ColumnDefinition Width="46.65"/>
        		<ColumnDefinition Width="*" MaxWidth="300"/>
        	</Grid.ColumnDefinitions>
        	<Grid.RowDefinitions>
        		<RowDefinition Height="40"/>
        		<RowDefinition Height="40"/>
        		<RowDefinition Height="40"/>
        		<RowDefinition Height="40"/>
        	</Grid.RowDefinitions>
        	<TextBlock Text="Name:" TextWrapping="Wrap" Margin="{DynamicResource TextBlockMargin}" VerticalAlignment="{DynamicResource TextBlockVerticalAlignemnt}" HorizontalAlignment="{DynamicResource TextBlockHorizontalAlignment}"/>
        	<TextBlock Margin="{DynamicResource TextBlockMargin}" Text="Side:" TextWrapping="Wrap" Grid.Row="1" VerticalAlignment="{DynamicResource TextBlockVerticalAlignemnt}" HorizontalAlignment="{DynamicResource TextBlockHorizontalAlignment}"/>
        	<TextBlock Margin="{DynamicResource TextBlockMargin}" Text="Position:" TextWrapping="Wrap" Grid.Row="2" VerticalAlignment="{DynamicResource TextBlockVerticalAlignemnt}" HorizontalAlignment="{DynamicResource TextBlockHorizontalAlignment}"/>
            <TextBox Margin="{DynamicResource EditControlMargin}" Style="{DynamicResource TextBoxStyle}" TextWrapping="Wrap" Grid.Column="1" VerticalAlignment="{DynamicResource EditControlVerticalAlignment}" HorizontalAlignment="{DynamicResource EditControlHorizontalAlignment}">
                <Binding Path="/Name" UpdateSourceTrigger="PropertyChanged" NotifyOnValidationError="True">
                    <Binding.ValidationRules>
                        <PresentationLayer:NameValidation></PresentationLayer:NameValidation>
                    </Binding.ValidationRules>
                </Binding>
            </TextBox>
            <TextBox Margin="{DynamicResource EditControlMargin}" Style="{DynamicResource TextBoxStyle}" Text="{Binding Path=/Position}" TextWrapping="Wrap" Grid.Row="2" Grid.Column="1" VerticalAlignment="{DynamicResource EditControlVerticalAlignment}" HorizontalAlignment="{DynamicResource EditControlHorizontalAlignment}" PreviewTextInput="TextBox_PreviewTextInput" />
        	<ComboBox Margin="{DynamicResource EditControlMargin}" Style="{DynamicResource ComboBoxStyle}" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Source={StaticResource sideData}}" SelectedValue="{Binding Path=/Side}" Grid.Row="1" Grid.Column="1" HorizontalAlignment="{DynamicResource EditControlHorizontalAlignment}" VerticalAlignment="{DynamicResource EditControlVerticalAlignment}"/>
        	<Button x:Name="ButtonAdd" Style="{DynamicResource ButtonLightStyle}" Content="Add new tavern" Click="ButtonAdd_Click" Height="Auto" Grid.Row="3" Grid.Column="1" HorizontalAlignment="{DynamicResource EditControlHorizontalAlignment}" Margin="5,5,5,5"/>
        </Grid>
    </Grid>
</UserControl>
